package cn.yunhe.model;

import java.util.Random;

/**
 * 图层类：二维表格
 */
public class Layer {

    private int offsetx;//偏移量 x轴
    private int offsety;//偏移量 y轴

    private Layer parent;//上⼀层图层对象

    private int rowNum;//⾏
    private int colNum;//列
    private int capacity;//最⼤容量
    private int size;//⽬前有多少牌,当牌添加和消失的时候改变

    //创建⼀个数组，存放所有的牌的名称，每次随机抽取⼀个牌的名字，因为每次进⼊地图，牌都是随机⽣成的。
    private Cell[][] cells;
    public Layer(int rowNum, int colNum) {
        this.rowNum = rowNum;
        this.colNum = colNum;
        this.capacity = this.rowNum * this.colNum;
        if (this.capacity % 3 != 0) {
            throw new RuntimeException("容量不是3的倍数..");
        }
        this.cells = new Cell[rowNum][colNum];
        //创建图层的时候通过随机数设置偏移量
        this.offsetx = new Random().nextInt(50);
        this.offsety = new Random().nextInt(50);
    }

    public Cell[][] getCells() {
        return cells;
    }

    public void setCells(Cell[][] cells) {
        this.cells = cells;
    }

    public int getRowNum() {
        return rowNum;
    }

    public void setRowNum(int rowNum) {
        this.rowNum = rowNum;
    }

    public int getColNum() {
        return colNum;
    }

    public void setColNum(int colNum) {
        this.colNum = colNum;
    }

    public int getCapacity() {
        return capacity;
    }

    public void setCapacity(int capacity) {
        this.capacity = capacity;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public int getOffsetx() {
        return offsetx;
    }

    public void setOffsetx(int offsetx) {
        this.offsetx = offsetx;
    }

    public int getOffsety() {
        return offsety;
    }

    public void setOffsety(int offsety) {
        this.offsety = offsety;
    }

    public Layer getParent() {
        return parent;
    }

    public void setParent(Layer parent) {
        this.parent = parent;
    }
}
